package com.sealer.pattern.structural.proxy.staticp.proxy;

import com.sealer.pattern.structural.proxy.staticp.service.AccountService;
import com.sealer.pattern.structural.proxy.staticp.service.impl.AccountServiceImpl;

/**
 * Created by sealer on 17/04/02.
 */
public class AccountServiceProxy implements AccountService {
    AccountServiceImpl accountService;

    public AccountServiceProxy(AccountServiceImpl accountService) {
        this.accountService = accountService;
    }

    @Override
    public void query() {
        if (accountService == null) {
            accountService = new AccountServiceImpl();
        }
        System.out.println("before query method");
        accountService.query();
        System.out.println("after query method");
    }

    @Override
    public void update() {
        if (accountService == null) {
            accountService = new AccountServiceImpl();
        }
        System.out.println("before update method");
        accountService.update();
        System.out.println("after update method");
    }
}
